import { FormInstance } from 'antd';
import React from 'react';
import { Dispatch } from 'react';

/** 需求页面上下文类型 */
export interface INeedContextAPI {
  styleFixCls: string;
  curRes: Record<string, any>;
  locationID: string;
  needDispatch: Dispatch<any>;
  pageType: string;
  oldNeedInfo: Record<string, any>;
  needForm: FormInstance | any;
  reloadDetail: () => void;
  needDetailInfo: Record<string, any>;
  tableData: Record<string, any>[];
  fetchEditNeed: (params: Record<string, any>) => void;
  nodesFlowListMemo: boolean;
  NumGatherMemo: Record<string, any>;
  setOAMessageRun: (res: Record<string, any>) => any;
  taskId: string;
}

/** 需求管理上下文 */
const INIT_NEEDCONTEXT_VALUE: INeedContextAPI = {
  styleFixCls: '',
  curRes: {},
  locationID: '',
  needDispatch: () => {},
  pageType: '',
  oldNeedInfo: {},
  needForm: {},
  reloadDetail: () => {},
  needDetailInfo: {},
  tableData: [],
  fetchEditNeed: () => {},
  nodesFlowListMemo: false,
  NumGatherMemo: {},
  setOAMessageRun: () => {},
  taskId: '',
};

const NeedControllerContext = React.createContext<INeedContextAPI>(INIT_NEEDCONTEXT_VALUE);

export { NeedControllerContext };
